home *** CD-ROM | disk | FTP | other *** search
- March 8, 1993
-
- GETOPT_.PAS & GETOPT2_.PAS
- A port from BorlandC's GETOPT.C made by Juancarlo Anez, CIS[73000,1064]
-
- Both units are very simple and autodocumented, so take a look at them.
-
- GETOPT_.PAS is the almost direct port. It lets you define and recognize
- normal switches and switches with arguments (like in PKZIP -bc:\tmp).
-
- GETOPT_2.PAS is the one I preffer. In this one, you only define switches
- that need arguments, so every '/x' sequence in the command line makes
- getopt return 'x' as a valid switch. Errors (invalid or not recognized
- switches) are then handled by the caller.
-
- Both units will return switch and non switch arguments. This is different
- from standard getotp, but I think it's better. You can ignore non-switches
- if you like.
-
- Both units leave the number of non swith arguments in the variable ArgC,
- and pointers to this arguments in the array ArgV[]. This lets you process
- switches first, and then carry on with non switch arguments.
-
- The test program uses one or the other unit depending on the definition
- of the OPT2 define. If you wan't to try GETOPT2_, then put
-
- {$DEFINE OPT2}
-
- as the first line in your program. If you wan't to try GETOPT_, then
- don't define OPT2. That's all.
-
- Run TESTO.BAT for a demo of assorted switches.
-
- Feel free to e-mail or post in GO BPASCAL any bugs or comments.
-
- Enjoy. -(j)